<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>吃什么</title>
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <% include ../include/head.ejs %>
        <link rel="stylesheet" href="/stylesheets/mycss.css" >
        <script>
            function saveItem(){
                var groupName = $("#groupName").val();
                var groupItem = $("#groupItem").val();
                if(!groupName){
                    $.toast("请填写名称", "text");
                    return;
                }
                if(!groupItem){
                    $.toast("请填写内容项", "text");
                    return;
                }
                $.ajax({
                    url:"addGroup",
                    data:{groupName:groupName,groupItem:groupItem},
                    success:function(data){
                        console.log(data);
                        if(data="ok"){
                            $.toast("添加成功", "text");
                            window.location.href = "/user/group";
                        }
                    }
                });
            }
        </script>
    </head>
    <body>
        <div class="weui-tab">
            <div class="weui-tab__bd">
                <div class="weui-tab__bd-item weui-tab__bd-item--active">
                    <div class="weui-cells__title">爱好组</div>
                    <div class="weui-cell">
                        <div class="weui-cell__hd">
                        <label for="" class="weui-label">名称</label>
                        </div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="text" value="" id="groupName" name="groupName">
                        </div>
                    </div>
                    <div class="weui-cell">
                        <div class="weui-cell__hd">
                        <label for="" class="weui-label">内容项</label>
                        </div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="input" placeholder="以;分割" id="groupItem" name="groupItem">
                        </div>
                    </div>
                    <div class="weui-cell">
                    </div>
                    <a href="javascript:;" class="weui-btn weui-btn_primary" onclick="saveItem()">保存</a>
                </div>
            </div>
        </div>
        <% include ../include/nav.ejs %>
        <% include ../include/head-js.ejs %>
    </body>
</html>